<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	String error = request.getParameter("error")==null?"": request.getParameter("error").toString();
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%> 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>欢迎登录后台管理系统</title>
<link href="../../css/login.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../easyui-1.5/jquery.min.js"></script>
<script type="text/javascript" src="../../js/jquery.browser.min.js"></script>
<script type="text/javascript" src="../../js/jquery.cookie.js"></script>
<script type="text/javascript" src="../../js/jquery.base64.js"></script>
<script type="text/javascript" src="../../easyui-1.5/jquery.easyui.min.js"></script>
<script type="text/javascript">

	$(function(){
		
		if ($.cookie('bit') == 'true') {
			var password=$.cookie('password');
		      $('#remember-me').attr('checked', 'checked');
		      $('#username').val($.cookie('username'));
		      $('#password').val($.base64.decode(password));
		    }
		
		//定义回车键登录
		$("body").keydown(function() {
		    if (event.keyCode == "13") {//keyCode=13是回车键
		        $("#login").click();
		    }
		}); 
	});
	
	 
	
	function submitlogin(){
		
			var username = $("#username").val(); 
			var password = $("#password").val();
			
			$.ajax({
				
				type:'POST',
				url:'adminlogin',
				data:{
					username:username,
					password:password
				},
				success: function(result) {
			          if ( result == 1) {
			            if ($('#remember-me').is(':checked'))
			            {
			              $.cookie('username', username, {
			                expires: 7
			              });
			              $.cookie('password',$.base64.encode(password), {
			                expires: 7
			              });
			              $.cookie('bit', 'true', {
			                expires: 7
			              });
			            } 
			            else {
			              $.removeCookie('username');
			              $.removeCookie('password');
			              $.removeCookie('bit');
			            }
			            <%-- var explorer =navigator.userAgent ;
			             if(explorer.indexOf("Chrome") >= 0)
			            {
			            	alert("Chrome");
					        window.location="<%=basePath%>jsp/manager/main.jsp";

			            	
			            }
			            if (explorer.indexOf("Firefox") >= 0) {
			            	alert("Firefox");
			                window.location.assign("<%=basePath%>jsp/manager/main.jsp");
			            } --%>
				        	window.location="main.jsp?";

			            
			          } 
			          else {
			        	  $.removeCookie('username');
			              $.removeCookie('password');
			              $.removeCookie('bit');
						  $("#error").html("用户名或者密码输入错误！");
			          }
			        }
			});
	}
	function reset(){
		
		$("#username").val("");
		$("#password").val("");
	}

</script>

</head>

<body>
	<div class="main-login">

		<div class="login-content">
			<h2 style="color: #87CEFA">陕西人才知识库后台管理</h2>

			<form action="adminlogin" method="post" id="login-form"
				name="login-form">
				
				<div class="login-info">
					<span class="user">&nbsp;</span> <input name="username"
						id="username" type="text" value="" class="login-input" />
				</div>
				<div class="login-info">
					<span class="pwd">&nbsp;</span> <input name="password"
						id="password" type="password" value="" class="login-input" />
				</div>
				<div class="login-oper">
					<input style="margin: 1px 10px 0px 2px; float: left;" name="remember-me" id="remember-me"
						type="checkbox" value=""  /><span>记住我</span>
						<div style="margin: 5px 0px;" id="message">
					         <span><font color="red" size=3 id="error"></font></span>
						</div>
				</div>
				<div class="login-oper">
					<input name="" type="button" value="登 录" class="login-btn" id="login" onclick="submitlogin();return false;"/> 
					<input name="" type="button" value="重 置" class="login-reset"  onclick="reset()"/>
				</div>
				
			</form>
		</div>
	</div>
</html>